<script>
	export default {
		onLoad() {


		},
		onLaunch: function() {
			// #ifdef APP-PLUS
						//设置2.4秒后主动关闭，最多设置6秒
						// setTimeout(() => {
							plus.navigator.closeSplashscreen();
						// }, 2400);
			// #endif
			plus.screen.lockOrientation("portrait-primary");
			var _this = this;
			// console.log('App Launch');
			// console.log(typeof(plus.runtime.version),typeof(plus.runtime.appid),typeof(plus.runtime.imei))
			

			uni.getSystemInfo({
				success: function(e) {
					Vue.prototype.statusBar = e.statusBarHeight
					// #ifndef MP
					if (e.platform == 'android') {
						Vue.prototype.customBar = e.statusBarHeight + 50
					} else {
						Vue.prototype.customBar = e.statusBarHeight + 45
					}
					// #endif

					// #ifdef MP-WEIXIN
					let custom = wx.getMenuButtonBoundingClientRect()
					Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
					// #endif

					// #ifdef MP-ALIPAY
					Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
					// #endif
				}
			})
		},
		onShow: function() {
			// console.log('App Show');
			// this.$store.commit('removeuser');
			var _this = this;
			uni.getNetworkType({
				success: function(res) {
					if (res.networkType == 'none') {
						uni.showToast({
							title: '当前无网络连接，请检查！',
							icon: 'none',
							duration: 5000,

							// position:'top'
						});
					}
				}
			});
			var user = uni.getStorageSync('userdata'),
				data = false;
			var vars = uni.getStorageSync('vars');
			if (vars) {
				this.$store.state.vars = true;
			};
			if (user) {
				data = JSON.parse(user);
			};
			this.$store.commit('setuser', data);
			this.$store.commit('init');
			// uni.showModal({
			//     title: 'app提示',
			//     content: '检测到你的账号已过期！',
			//     success: function (res) {
			//         if (res.confirm) {
			//             console.log('用户点击确定');
			//         } else if (res.cancel) {
			//             console.log('用户点击取消');
			//         }
			//     }
			// });
			setInterval(() => {
				if (!this.$store.state.user) return;
				uni.request({
					method: 'post',
					url: this.$store.state.url1 + '/api/ManagerLogin/checklogin',
					data: JSON.stringify({
						"token": this.$store.state.user.token,
						"exchangeArea": 0,
						"guid": Math.floor(Math.random() * 10000) + '',
						"timestamp": 0,
						"sign": "string"
					}),
					success: function(data) {
						data = data.data;
						// console.log(data)
						if (data.code == 401) {
							_this.$store.commit('removeuser', true);
							uni.showModal({
								title: 'app提示',
								content: '检测到你的账号已过期,是否重新登录？',
								success: function(res) {
									if (res.confirm) {
										_this.$go('/pages/login/login');
									} else if (res.cancel) {};
								}
							});
						}
					}
				})
			}, 3000);
			// console.log(user)
		},
		onHide: function() {
			console.log('App Hide');
		}
	};
</script>

<style>
	/* 解决头条小程序组件内引入字体不生效的问题 */
	uni-page-body,
	uni-page-refresh,
	uni-page-wrapper {
		/* background: #f7f7f7; */
		min-height: 100%;
	}

	.border-bt {
		position: relative;
	}

	.border-bt::before {
		transform: scaleY(0.5);
		content: '';
		width: 100%;
		height: 1rpx;
		background: #e5e5e5;
		position: absolute;
		bottom: 0;
		left: 0;
		z-index: 9;
	}

	.border-tp {
		position: relative;
	}

	.border-tp::after {
		transform: scaleY(0.5);
		content: '';
		width: 100%;
		height: 1rpx;
		background: #e5e5e5;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 9;
	}
	/* @font-face {
		font-family: newicons;
		src: url('~@/static/new.ttf');
	} */
	@font-face {
		font-family: newicons;
		src: url('~@/static/PingFang1.ttf');
	}
	body{
		font-family: newicons;
	}
	@font-face {
		font-family: uniicons;
		src: url('~@/static/uni.ttf');	
	}
	/* #ifdef MP-TOUTIAO */
	@font-face {
		
		font-family: uniicons;
		src: url('~@/static/uni.ttf');	
	}

	/* #endif */
</style>
